package cn.wolfcode.trip.app.util;


import java.text.SimpleDateFormat;
import java.util.Date;

public class MessageDataUtil {
    public static Object getData(Date time) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.util.Date now = new Date();
        StringBuffer sb= null;
        try {
            long l = now.getTime() - time.getTime();
            long day = l / (24 * 60 * 60 * 1000);
            long hour = (l / (60 * 60 * 1000) - day * 24);
            long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60);
            long s = (l / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);

           sb = new StringBuffer();
           sb.append("---------");
            if (day > 0)
                sb.append(day + "天");
            if (hour > 0)
                sb.append(hour + "小时");
            if (min > 0)
                sb.append(min + "分");
            sb.append(s + "秒 前");
        } catch (Exception e) {

            e.printStackTrace();
        }
        return sb;
    }

}
